<template>
    <div>
        <!-- 前一个值是发送方，后一个值是本地方 -->
        <detail-banner
            :sightName='sightName'
            :bannerImg='bannerImg'
            :bannerImgs='gallaryImgs'
        >
        </detail-banner>
        <detail-header></detail-header>
        <div class="content">
            <detail-list :list='list'></detail-list>
        </div>
    </div>
</template>

<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import axios from 'axios'
export default {
    /*
        name的用途：
        1.递归组件的时候会用到它
        2.对某个页面取消缓存的时候
        3.vue调试台，你name设置的时候值，vue调试台组件也是什么值
    */ 
    name: 'Detail',
    components: {
        DetailBanner,
        DetailHeader,
        DetailList
    },
    data() {
        return {
            sightName: '',
            bannerImg: '',
            gallaryImgs: [],
            list: [],
        }
    },
    methods: {
        getDetailInfo(){
            axios.get('/api/detail.json', {
                params: {
                    id: this.$route.params.id
                }
            }).then(this.handleDataSuccInfo)
        },
        // 会接收一个res参数
        handleDataSuccInfo(res){
            res = res.data
            if(res.ret && res.data){
                const data = res.data
                // console.log(data)
                this.sightName = data.sightName
                this.bannerImg = data.bannerImg
                this.gallaryImgs = data.gallaryImgs
                this.list = data.categoryList
            }
        }
    },
    mounted() {
        this.getDetailInfo()
    },
}
</script>

<style lang="stylus" scoped>
    .content
        height 50rem
</style>